'  ==========================================================================
'  |                                                                        |
'  | SQLitening Special API                                                 |
'  |                                                                        |
'  ==========================================================================
'   Contains routines, called from any program that supports OLE 
'   string parameter passing but only ByRef (like Visual Basic),  to 
'   access a SQLite databases and flat files residing locally or 
'   remotely (using SQLitening Server). Must also support optional 
'   parameters SQLiteningS.Dll is a front-end to SQLitening.Dll. See 
'   SQLitening.Txt or SQLitening.Chm for information on each command. 
' 
'  ==========================================================================
'  PUBLIC DOMAIN SOFTWARE
'  The author or authors of this code dedicate any and all
'  copyright interest in this code to the public domain.
'  Anyone is free to copy, modify, publish, use, compile,
'  sell, or distribute the original code, either in source
'  code form or as a compiled binary, for any purpose,
'  commercial or non-commercial, and by any means.
'  Fred Meier - July 2010
' 
'  ==========================================================================

#Compile Dll "..\Bin\SQLiteningS.Dll"
#Dim All
#Include "..\Inc\SQLitening.Inc"

'=======================<[ Equates and Types ]>========================

' ==========>>> Misc
%True = -1
%False = 0

'=============================<[ Attach ]>=============================
Function slsAttach alias "slsAttach" (rsFileName as String, _
                                      rsAsDatabaseName as String, _
                                      optional rsModChars as String)Export as Long
   function = slAttach(rsFileName, rsAsDatabaseName, iif$(ismissing(rsModChars), "", rsModChars))
End Function

'==========================<[ BuildBindDat ]>==========================
Function slsBuildBindDat alias "slsBuildBindDat" (rsData as String, _
                                                  optional rsModChars as String) Export as String
   function = slBuildBindDat(rsData, iif$(ismissing(rsModChars), "", rsModChars))
End Function

'======================<[ BuildInsertOrUpdate ]>=======================
Function slsBuildInsertOrUpdate alias "slsBuildInsertOrUpdate" (rsTable as String, _
                                                                rsValues as String, _
                                                                optional rsColumns as String, _
                                                                optional rsWhere as String) Export as String
   function = slBuildInsertOrUpdate(rsTable, rsValues, iif$(ismissing(rsColumns), "", rsColumns), iif$(ismissing(rsWhere), "", rsWhere))
End Function

'============================<[ Connect ]>=============================
Function slsConnect alias "slsConnect" (optional rsServer as String, _
                                        optional byval rlPort as Long, _
                                        optional rsModChars as String, _
                                        optional wsOutData as String) Export as Long
   function = slConnect(iif$(ismissing(rsServer), "", rsServer), rlPort, iif$(ismissing(rsModChars), "", rsModChars), iif$(ismissing(wsOutData), "", wsOutData))
End Function

'===========================<[ ConvertDat ]>===========================
Function slsConvertDat alias "slsConvertDat" (rsData as String, _
                                              optional rsModChars as String) Export as String
   function = slConvertDat(rsData, iif$(ismissing(rsModChars), "", rsModChars))
End Function

'=========================<[ Copy Database ]>==========================
Function slsCopyDatabase alias "slsCopyDatabase" (rsDestinationFileName as String, _
                                                  optional rsModChars as String, _
                                                  optional rsDatabaseName as String)Export as Long
   function = slCopyDatabase(rsDestinationFileName, iif$(ismissing(rsModChars), "", rsModChars), iif$(ismissing(rsDatabaseName), "", rsDatabaseName))
End Function

'==============================<[ Exe ]>===============================
Function slsExe alias "slsExe" (rsStatement as String, _
                                optional rsModChars as String)Export as Long
   function = slExe(rsStatement, iif$(ismissing(rsModChars), "", rsModChars))
End Function

'============================<[ Exe Bind ]>============================
Function slsExeBind alias "slsExeBind" (rsStatement as String, _
                                        rsBindDats as String, _
                                        optional rsModChars as String)Export as Long
   function = slExeBind(rsStatement, rsBindDats, iif$(ismissing(rsModChars), "", rsModChars))
End Function

'=======================<[ Field Get Extended ]>=======================
Function slsFX alias "slsFX" (byval rlColumnNumber as Long, _
                              optional rsModChars as String, _
                              optional byval rlSetNumber as Long)Export as String
   function = slFX(rlColumnNumber, iif$(ismissing(rsModChars), "", rsModChars), rlSetNumber)
End Function

'====================<[ Field Name Get Extended ]>=====================
Function slsFNX alias "slsFNX" (rsColumnName as String, _
                                optional rsModChars as String, _
                                optional byval rlSetNumber as Long)Export as String
   function = slFNX(rsColumnName, iif$(ismissing(rsModChars), "", rsModChars), rlSetNumber)
End Function

'========================<[ Get Change Count ]>========================
Function slsGetChangeCount alias "slsGetChangeCount" (optional rsModChars as String)Export as Long
   function = slGetChangeCount(iif$(ismissing(rsModChars), "", rsModChars))
End Function

'============================<[ Get File ]>============================
Function slsGetFile alias "slsGetFile" (rsFileName as String, _
                                        wsFileData as String, _
                                        optional rsModChars as String)Export as Long
   function = slGetFile(rsFileName, wsFileData, iif$(ismissing(rsModChars), "", rsModChars))
End Function

'===========================<[ Get Handle ]>===========================
Function slsGetHandle alias "slsGetHandle" (optional rsModChars as String, _
                                            optional byval rlSetNumber as Long)Export as Dword
   function = slGetHandle(iif$(ismissing(rsModChars), "", rsModChars), rlSetNumber)
End Function

'=========================<[ Get Insert ID ]>==========================
Function slsGetInsertID alias "slsGetInsertID" ()Export as Quad
   function = slGetInsertID()
End Function

'============================<[ Get Row ]>=============================
Function slsGetRow alias "slsGetRow" (optional byval rlSetNumber as Long, _
                                      optional rsModChars as String)Export as Long
   function = slGetRow(rlSetNumber, iif$(ismissing(rsModChars), "", rsModChars))
End Function

'========================<[ Get Table Names ]>=========================
Function slsGetTableNames alias "slsGetTableNames" (optional rsDataBase as String)Export as String
   function = slGetTableNames(iif$(ismissing(rsDataBase), "", rsDataBase))
End Function

'==============================<[ Open ]>==============================
Function slsOpen alias "slsOpen" (optional rsFileName as String, _
                                  optional rsModChars as String) Export as Long
   function = slOpen(iif$(ismissing(rsFileName), "", rsFileName), iif$(ismissing(rsModChars), "", rsModChars))
End Function

'============================<[ Put File ]>============================
Function slsPutFile alias "slsPutFile" (rsFileName as String, _
                                        rsFileData as String, _
                                        optional rsModChars as String)Export as Long
   function = slPutFile(rsFileName, rsFileData, iif$(ismissing(rsModChars), "", rsModChars))
End Function

'============================<[ Run Proc ]>============================
Function slsRunProc alias "slsRunProc" (rsProcName as String, _
                                        blParm1 as Long, _
                                        blParm2 as Long, _
                                        bsParm3 as String, _
                                        bsParm4 as String, _
                                        optional rsModChars as String)Export as Long
   function = slRunProc(rsProcName, blParm1, blParm2, bsParm3, bsParm4, rsModChars)
End Function

'==============================<[ Sel ]>===============================
Function slsSel alias "slsSel" (rsStatement as String, _
                                optional byval rlSetNumber as Long, _
                                optional rsModChars as String)Export as Long
   function = slSel(rsStatement, rlSetNumber, iif$(ismissing(rsModChars), "", rsModChars))
End Function

'============================<[ Sel Str ]>=============================
Function slsSelStr alias "slsSelStr" (rsStatement as String, _
                                      optional rsModChars as String)Export as String
   function = slSelStr(rsStatement, iif$(ismissing(rsModChars), "", rsModChars))
End Function

'======================<[ Sel Rel Named Locks ]>=======================
Function slsSetRelNamedLocks alias "slsSetRelNamedLocks" (byref rsLockNames as String, _
                                                          optional byref rsModChars as String, _
                                                          optional byref rsSelStatement as String, _
                                                          optional byval rlSelSetNumber as Long, _
                                                          optional byref rsSelModChars as String) Export as Long
   function = slSetRelNamedLocks(rsLockNames, iif$(ismissing(rsModChars), "", rsModChars), _
                                              iif$(ismissing(rsSelStatement), "", rsSelStatement), _
                                              rlSelSetNumber, _
                                              iif$(ismissing(rsSelModChars), "", rsSelModChars))
End Function

